<template>
  <div class="container">
    <div class="screen" ref="screenEle">
      <Top />
      <div class="bottom">
        <div class="left">
          <Tourist />
          <Sex />
          <Age />
        </div>
        <div class="center">
          <Map></Map>
          <Line></Line>
        </div>
        <div class="right">
          <Rank></Rank>
          <Year></Year>
          <Couter></Couter>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
const screenEle = ref<HTMLDivElement>();

onMounted(() => {
  (screenEle as Ref<HTMLDivElement>).value.style.transform = `scale(${getScale()}) translate(-50%, -50%)`;
});

const getScale = (w = 1920, h = 1080) => {
  const ww = window.innerWidth / w;
  const wh = window.innerHeight / h;

  return ww < wh ? ww : wh;
};

window.onresize = () => {
  (screenEle as Ref<HTMLDivElement>).value.style.transform = `scale(${getScale()}) translate(-50%, -50%)`;
};
</script>

<style lang="scss" scoped>
.container {
  width: 100vw;
  height: 100vh;
  background: url('./images/bg.png') no-repeat;
  background-size: cover;

  .screen {
    width: 1920px;
    height: 1080px;
    position: fixed;
    transform-origin: left top;
    left: 50%;
    top: 50%;

    .bottom {
      width: 100%;
      height: calc(100% - 40px);
      display: grid;
      grid-template-columns: 1.2fr 3fr 1.2fr;

      .left {
        display: grid;
        grid-template-rows: 1fr 1fr 1fr;

        > div {
          margin: 10px;
        }
      }
      .center {
        display: grid;
        grid-template-rows: 3fr 1fr;
        > div {
          margin: 10px;
        }
      }
      .right {
        display: grid;
        grid-template-rows: 1fr 1fr 1fr;

        > div {
          margin: 10px;
        }
      }
    }
  }
}
</style>
